import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入全局样式表
import './assets/css/global.css'
// 引入全局axios 这样每一个vue组件实例都可以访问 $http 从而发送AJAX请求
import axios from 'axios'
// 引入vue-table-with-tree-grid
import TreeTable from 'vue-table-with-tree-grid'
Vue.prototype.$http = axios
// 使用 vue-table-with-tree-grid
// 两个参数，前面是注册插件的名字，后面是注册的插件
Vue.component('tree-table', TreeTable)

// 设置AJAX根路径请求
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})
Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
